# x and y given as array_like objects
# import plotly.express as px
# fig = px.scatter(x=[0, 1, 2, 3, 4], y=[0, 1, 4, 9, 16])
# fig.show()


# x and y given as DataFrame columns
# import plotly.express as px
# df = px.data.iris() # iris is a pandas DataFrame
# # print(df.head())
# fig = px.scatter(df, x="sepal_width", y="sepal_length")
# fig.show()

# 三维散点图
# import plotly.express as px
#
# # 加载iris数据集
# df = px.data.iris()
#
# # 创建3D散点图
# fig = px.scatter_3d(df, x="sepal_width", y="sepal_length", z="petal_length", color="species")
#
# # 显示图表
# fig.show()


# 作业
import plotly.express as px

# 加载iris数据集
df = px.data.iris()

# 创建3D散点图，将第四维数据映射到颜色和大小
fig = px.scatter_3d(
    df,
    x="sepal_width",  # x轴
    y="sepal_length",  # y轴
    z="petal_length",  # z轴
    color="petal_width",  # 第四维：颜色
    size="petal_width",  # 第四维：点的大小
    hover_name="species",  # 悬停时显示的种类名称
    title="4D Iris Data Visualization"
)

# 显示图表
fig.show()